<?php
    // process action cancel/agree object abused.
    $act  = isset ($_GET['act']) ? $_GET['act'] : '';
    $guid = isset ($_GET['guid']) ? intval($_GET['guid']) : '';
    
    if($act == 'cancel') {
        $obj_process = get_entity($guid);
	$obj_process->clearMetaData(ABUSED);
	$obj_process->save();
        $obj_process->setMetaData(ABUSED, -1);
    } else if($act == 'agree') {
        $obj_process = get_entity($guid);
	$obj_process->clearMetaData(ABUSED);
	$obj_process->save();
        $obj_process->setMetaData(ABUSED, 1);
    }
?>

<style type="text/css">
    /*
* BEGIN : CSS for OPINIONS ADMINISTRATION PAGE
*/

#table-abuse-header {
    width: 674px;
    padding: 8px 0;
    color: #4690D6;
    font-weight: bold;
    background-color: #e5e5e5;
    float: left;
}

.col-order, .col-interest, .col-reason, .col-numofreports, .col-cancel, .col-delete {
    float: left;
}

.row-abuse {
    border-top: 1px solid #CCCCCC;
    clear: both;
    height: 17px;
    padding: 10px 0;
    width: 674px;
    margin-right: 4px;
}

.col-order, .col-cancel, .col-delete {
    width: 70px;
}

.col-interest {
    width: 200px;
}

.col-reason {
    width: 144px;
}

.col-numofreports {
    width: 120px;
}

.div-clear {
    clear: both;
}

.col-cancel a,
.col-cancel a:link,
.col-cancel a:visited {
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    border-radius: 5px;
    text-decoration: none;
    color: #ffffff;
    background-color: #4690D6;
    padding: 5px;
    cursor: pointer;
}

.col-cancel a:hover {
    background-color: #E5E5E5;
}

.col-delete a,
.col-delete a:link,
.col-delete a:visited {
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    border-radius: 5px;
    text-decoration: none;
    color: #ffffff;
    background-color: #FF3D3D;
    padding: 5px 8px;
    cursor: pointer;
}

.col-delete a:hover {
    background-color: #E5E5E5;
}


/*
* END : CSS for OPINIONS ADMINISTRATION PAGE
*/
</style>

<div align="center"> 
    <div id="table-abuse-header">
        <div class="col-order">GUID</div>
        <div class="col-interest">Interest Name</div>
        <div class="col-reason">Reason</div>
        <div class="col-numofreports">Num of Reports</div>
        <div class="col-cancel">Cancel</div>
        <div class="col-delete">Agree</div>
    </div>
    <?php
        $interests = greengar_opinions_get_abuse_interest();
        foreach($interests as $interest) {
            $interest_object = $interest->toArray();
    ?>
            <div class="row-abuse">
                <div class="col-order"><?php echo $interest_object['guid']; ?></div>
                <div class="col-interest"><?php echo $interest_object['name']; ?></div>
                <div class="col-reason"><?php echo '...'; ?></div>
                <div class="col-numofreports"><?php echo count($interest->getMetaData(REPORTED)); ?></div>
                <div class="col-cancel"><a href="<?php echo 'http://' . $_SERVER["SERVER_NAME"] . '/elgg_dev/mod/greengar/opinions/moderation/pages/admin.php?tab=reportedinterests&act=cancel&guid=' . $interest_object['guid'] ; ?>">Cancel</a></div>
                <div class="col-delete"><a href="<?php echo 'http://' . $_SERVER["SERVER_NAME"] . '/elgg_dev/mod/greengar/opinions/moderation/pages/admin.php?tab=reportedinterests&act=agree&guid=' . $interest_object['guid'] ; ?>">Agree</a></div>
            </div>
            <div class="div-clear"></div>   
    <?php
        }
    ?>
</div>
<?php
/*
echo greengar_opinions_countAbused(INTEREST_PARENT, INTEREST_SUBTYPE, ELGG_ENTITIES_ANY_VALUE);
echo "<br>";
$entities = greengar_opinions_countAbused(INTEREST_PARENT, INTEREST_SUBTYPE, ELGG_ENTITIES_ANY_VALUE);
foreach ($entities as $entity) {
    echo elgg_view_entity($entity);
}
 
 */
?>